<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="common/header.jsp"%>
<div class="clearfix"></div>
<div class="row">
  <div class="col-md-12 col-sm-12 col-xs-12">
    <div class="x_panel">
      <div class="x_title">
        <h2>新增手游基础信息 <i class="fa fa-user"></i><small>${devUserSession.devName}</small></h2>
             <div class="clearfix"></div>
      </div>
      <div class="x_content">
           <div class="clearfix"></div>
        <form class="form-horizontal form-label-left" id="ch"  action="appinfoaddsave" method="post" enctype="multipart/form-data">
        </form>
      </div>
    </div>
  </div>
</div>
<%@include file="common/footer.jsp"%>
<script src="${pageContext.request.contextPath }/statics/localjs/appinfoadd.js"></script>
<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
  function getUrlParam(name) {
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r!=null) return unescape(r[2]);
    return null;
  }
    $(function () {
      var id = getUrlParam("id");
      $.ajax({
        "url":"/XiangMu_war_exploded/indexAi",
        "type":"post",
        "data":{"id":id},
        "dataType":"json",
        "success":function(r){
          var appinfo = JSON.parse(r)
          var html = "";
          html+=' 软件名称：<input type="text" id="softwareName" value='+appinfo.softwareName+'><br/>'
          html+=' apk名称：<input type="text" id="APKName" value='+appinfo.apkName+'><br/>'
          html+=' 支持ROM：<input type="text" id="supportROM" value='+appinfo.supportRom+'><br/>'
          html+=' 支持语言：<input type="text" id="interfaceLanguage" value='+appinfo.interfaceLanguage+'><br/>'
          html+=' 软件大小：<input type="text" id="softwareSize" value='+appinfo.softwareSize+'><br/>'
          html+=' 下载次数：<input type="text" id="downloads" value='+appinfo.downloads+'><br/>'
          var pingtai = null;
          if(appinfo.flatformId==0){
            pingtai="Steam";
          }else{
            pingtai="暴雪平台"
          }
          html+='所属平台：<input type="text" id="flatformId" value='+pingtai+'><br/>'
          html+='状态：<input type="text" id="status" value='+appinfo.status+'><br/>'
          html+='应用简介：<input type="text" id="appInfo" value='+appinfo.appInfo+'><br/>'
          html+='<input type="button" onclick=xiugai() value="修改">'
          $("#ch").append(html);
        },
        "error":function(){
          alert("服务器错误");
        }
      })
    })

    function xiugai() {
      var id = getUrlParam("id");
      var softwareName = $("#softwareName").val();
      var apkName = $("#APKName").val();
      var supportRom = $("#supportROM").val();
      var interfaceLanguage = $("#interfaceLanguage").val();
      var flatform = $('#flatformId').val();
      var flatformId = null;
      if(flatform=="暴雪战网"){
        flatformId=0
      }else{
        flatformId=1
      }
      var softwareSize = $("#softwareSize").val();
      var downloads = $("#downloads").val();
      var appInfo = $("#appInfo").val();

      $.ajax({
        "url":"/XiangMu_war_exploded/updateAi",
        "type":"get",
        "data":{
          "id":id,
          "softwareName":softwareName,
          "apkName":apkName,
          "supportRom":supportRom,
          "interfaceLanguage":interfaceLanguage,
          "flatformId":flatformId,
          "softwareSize":softwareSize,
          "downloads":downloads,
          "appInfo":appInfo
        },
        "dataType":"text",
        "success":function(result){
          if(result=="true"){
            alert("修改成功");
            window.location.href="/XiangMu_war_exploded/toselAp";
          }else{
            alert("修改失败");
          }
        },
        "error":function(){
          alert("服务器错误");
        }
      });
    }
</script>